Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: ""
    },
    home: {
      type: Boolean,
      value: false
    },
    back: {
      type: Boolean,
      value: true
    },
    bg: {
      type: Boolean,
      value: false
    },
    fixed: {
      type: Boolean,
      value: true
    },
    space: {
      type: Boolean,
      value: true
    },
    white: {
      type: Boolean,
      value: false
    },
    hook: {
      type: Boolean,
      value: false
    },
    transparent: {
      type: Boolean,
      value: false
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    height: 0,
    statusBarHeight: 0
  },

  /**
   * 组件生命周期函数，在组件实例进入页面节点树时执行
   */
  attached() {
    const sysInfo = tt.getMenuButtonBoundingClientRect();
    this.setData({
      height: sysInfo.height,
      statusBarHeight: sysInfo.top,
    });
  },

  /**
   * 组件的方法列表
   */
  methods: {
    back() {
      if (this.data.hook) {
        this.triggerEvent('beforeLeave');
      } else {
        if (this.data.home) {
          tt.redirectTo({
              url: '../../pages/index/index',
          });
        } else {
          tt.navigateBack({
            delta: 1,
            fail: () => {
              tt.redirectTo({
                url: '../../pages/index/index',
              });
            },
          });
        }
        
      }
    },
  },
});
